package cn.edu.tsinghua.smxq.mobilecity.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.edu.tsinghua.smxq.mobilecity.po.FoodPriceSearch;
import cn.edu.tsinghua.smxq.mobilecity.utils.DBUtils;

public class FoodPriceSearchDAO {

	public boolean create(FoodPriceSearch foodPriceSearch) throws SQLException {
		boolean success = false;
		Connection conn = DBUtils.Connect();
		PreparedStatement pstmt = conn
				.prepareStatement("INSERT INTO mobilecity.foodpricesearch(userid,cityid,foodid,time) values(?,?,?,?)");
		pstmt.setInt(1, foodPriceSearch.getUserId());
		pstmt.setInt(2, foodPriceSearch.getCityId());
		pstmt.setInt(3, foodPriceSearch.getFoodId());
		pstmt.setTimestamp(4, foodPriceSearch.getTime());
	
		if (pstmt.executeUpdate() == 1) {
			success = true;
		}
		pstmt.close();
		conn.close();
		return success;
	}
}
